package com.sunni.controller;

import com.sunni.entity.Account;
import com.sunni.mapper.AccountMapper;
import org.apache.ibatis.io.ResolverUtil;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class 最后_动态SQL {
    public static void main(String[] args) {
        InputStream inputStream = ResolverUtil.Test.class.getClassLoader().getResourceAsStream("config.xml");
        SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();
        SqlSessionFactory sqlSessionFactory = sqlSessionFactoryBuilder.build(inputStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        AccountMapper accountMapper = sqlSession.getMapper(AccountMapper.class);

        HashMap<String , Object> map = new HashMap<>();
        map.put("id",0);
        map.put("username","wuwukai");
        map.put("password",null);
        map.put("age",null);

        ArrayList<Integer> ids = new ArrayList<>();
        ids.add(1);
        ids.add(2);
        ids.add(3);
//        Account account = accountMapper.findByIdAndUsername(map);
        List<Account> accountList = accountMapper.findByIds(ids);
        System.out.println(accountList);

    }
}
